#ifndef _SYS_URI_H_
#define _SYS_URI_H_

#include "FanObj.h"
#include "SysTypes.h"

#define URI_VTABLE(self)   ((UriVTable*)((FanObj*)self)->vtable)


extern Type*    Uri_classType;
extern VTable*  Uri_classVTable;


/* [sys::Uri] Attributes */
struct Uri
{
  FanObj        super;
  Str*          str;
  Str*          scheme;
  Str*          userInfo;
  Str*          host;
  NullableInt   port;
  List*         path;
  Str*          pathStr;
  Map*          query;
  Str*          queryStr;
  Str*          frag;
  Str*          encoded;
};


/* [sys::Uri] Virtual-table */
typedef struct UriVTable
{
  FanObjVTable  super;
} UriVTable;


/* [sys::Uri] Methods and fields */
Bool            Uri_equals(Obj self, NullableObj that);
Int             Uri_hash(Obj self);
Str*            Uri_toStr(Obj self);
Uri*            Uri_defVal(void);
Uri*            Uri_fromStr_1(Str* s);
Uri*            Uri_fromStr(Str* s, Bool checked);
Uri*            Uri_decode_1(Str* s);
Uri*            Uri_decode(Str* s, Bool checked);
Map*            Uri_decodeQuery(Str* s);
Str*            Uri_encode(Uri* self);
Str*            Uri_encodeQuery(Map* q);
Bool            Uri_isName(Str* name);
void            Uri_checkName(Str* name);
Str*            Uri_toLocale(Uri* self);
Bool            Uri_isAbs(Uri* self);
Bool            Uri_isRel(Uri* self);
Bool            Uri_isDir(Uri* self);
Str*            Uri_scheme(Uri* self);
Str*            Uri_auth(Uri* self);
Str*            Uri_host(Uri* self);
Str*            Uri_userInfo(Uri* self);
NullableInt     Uri_port(Uri* self);
List*           Uri_path(Uri* self);
Str*            Uri_pathStr(Uri* self);
Bool            Uri_isPathAbs(Uri* self);
Bool            Uri_isPathOnly(Uri* self);
Str*            Uri_name(Uri* self);
Str*            Uri_basename(Uri* self);
Str*            Uri_ext(Uri* self);
MimeType*       Uri_mimeType(Uri* self);
Map*            Uri_query(Uri* self);
Str*            Uri_queryStr(Uri* self);
Str*            Uri_frag(Uri* self);
Uri*            Uri_parent(Uri* self);
Uri*            Uri_pathOnly(Uri* self);
Uri*            Uri_getRange(Uri* self, Range* r);
Uri*            Uri_getRangeToPathAbs(Uri* self, Range* r);
Uri*            Uri_plus(Uri* self, Uri* toAppend);
Uri*            Uri_plusName_1(Uri* self, Str* name);
Uri*            Uri_plusName(Uri* self, Str* name, Bool asDir);
Uri*            Uri_plusSlash(Uri* self);
Uri*            Uri_plusQuery(Uri* self, Map* query);
Uri*            Uri_relTo(Uri* self, Uri* base);
Uri*            Uri_relToAuth(Uri* self);
File*           Uri_toFile(Uri* self);
NullableObj     Uri_get_0(Uri* self);
NullableObj     Uri_get_1(Uri* self, NullableObj base);
NullableObj     Uri_get(Uri* self, NullableObj base, Bool checked);
Str*            Uri_toCode(Uri* self);


/* [sys::Uri] Extra methods */
Uri*            Uri_newUnitialized();


/* [sys::Uri] Type-system functions */
Type*           Uri_initType(void);
VTable*         Uri_initVTable(void);
void            Uri_initStatic(void);


#endif
